package com.metacube.metaconnect.model;

import javax.servlet.http.HttpServletRequest;

import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.ActionMessage;

public class UpdateProfileForm extends ActionForm {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private String email;
	private String name;
	private String contact_number;
	private String project_name;
	private String designation;

	public String getEmail() {
		return email;
	}

	public void setEmail(String email) {
		this.email = email;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getContact_number() {
		return contact_number;
	}

	public void setContact_number(String contact_number) {
		this.contact_number = contact_number;
	}

	public String getProject_name() {
		return project_name;
	}

	public void setProject_name(String project_name) {
		this.project_name = project_name;
	}

	public String getDesignation() {
		return designation;
	}

	public void setDesignation(String designation) {
		this.designation = designation;
	}

	public ActionErrors validate(ActionMapping mapping,
			HttpServletRequest request) {

		ActionErrors errors = new ActionErrors();
		try {
			if (name.equals(""))
				errors.add("name", new ActionMessage("MetaConnect.error.name"));
			if (!contact_number.matches("^[0-9]{10}$"))
				errors.add("contact_number", new ActionMessage(
						"MetaConnect.error.contact"));

			if (!errors.isEmpty())
				request.setAttribute("errorInUpdate",
						"Invalid input supplied!!!! profile could not be updated");
		} catch (Exception e) {
			e.printStackTrace();
		}
		return errors;
	}

}
